package com.dpiinc.TechPage.repository
import androidx.lifecycle.MutableLiveData
import androidx.paging.DataSource
import com.dpiinc.TechPage.api.NoteListApi
import com.dpiinc.TechPage.room.bean.NoteEntity
import java.util.concurrent.Executor

/**
 * SearchNoteSourceFactory
 * Created by X on 2018/7/28.
 */
class SearchNoteSourceFactory(
        private val noteListApi: NoteListApi,
        private val keyword: String,
        private val searchType: Int,
        private val retryExecutor: Executor) : DataSource.Factory<String, NoteEntity>() {
    val sourceLiveData = MutableLiveData<SearchNoteDataSource>()
    override fun create(): DataSource<String, NoteEntity> {
        val source = SearchNoteDataSource(noteListApi, keyword,searchType, retryExecutor)
        sourceLiveData.postValue(source)
        return source
    }
}
